package com.gitee.hermer.engine.jars.demo.core.provide.jobs;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.gitee.hermer.boot.jee.commons.log.UtilsContext;
import com.gitee.hermer.boot.jee.commons.utils.StringUtils;
import com.gitee.hermer.engine.jars.core.annotate.EngineComponent;
import com.gitee.hermer.engine.jars.core.annotate.EngineAppJob;
import com.gitee.hermer.engine.jars.demo.core.provide.po.TestPO;
import com.gitee.hermer.engine.jars.demo.core.provide.po.TestPOExample;
import com.gitee.hermer.engine.jars.demo.core.provide.test.dao.TestDao;

@EngineComponent
public class TestServiceImpl extends UtilsContext{

	@Autowired
	private TestDao dao;

	@EngineAppJob(jobMethod = "updateTestPO")
	@Transactional
	public String updateTestPO(){
//		TestPOExample example = new TestPOExample();
//		example.createCriteria().andCreateOwnerEqualTo("admin");
		TestPO record = new TestPO();
		String code = StringUtils.getRandomString(5);
		record.setCode(code);
//		TestPO temp = (TestPO) dao.selectByExample(example).get(0);
		TestPOExample example =  new TestPOExample();
		example.createCriteria().andIdEqualTo("5880002");
		dao.updateByExample(record, example);
		return code;
	}
	
	@EngineAppJob(jobMethod = "selectTestPO")
	public List selectTestPO(String code){
		TestPOExample example = new TestPOExample();
		example.createCriteria().andCodeEqualTo(code);
		return dao.selectByExample(example);
	}

}
